package com.cindata

class Comment
{
    String comment
    User user

    Date createdDate = new Date()
    Date modifiedDate = new Date()

    static belongsTo = [collateral: Collateral, riskWarning: RiskWarning, abnormalMortgageBatch: AbnormalMortgageBatch, account: Account]

    static mapping = {
        autowire true
    }

    static constraints = {
        comment nullable: false, blank: false
        comment type: "text"
        user nullable: true, blank: true
        collateral nullable: true, blank: true
        riskWarning nullable: true, blank: true
        abnormalMortgageBatch nullable: true, blank: true
        account nullable: true, blank: true
    }

    def springSecurityService

    def beforeInsert()
    {
        user = User.findByUsername(springSecurityService?.getPrincipal()?.username)
    }

    def beforeUpdate()
    {
        modifiedDate = new Date()
    }
}
